package com.example.demo.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author Rocket
 * @version 10.0.1
 * @date 2021-08-15 9:48 AM
 */
@WebServlet(name="identify browser", urlPatterns = {"/identify"})
public class IdentifyBrowser extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        String userAgent = req.getHeader("user-agent");
        if(userAgent.indexOf("Chrome") != -1) {
            resp.getWriter().println("Your browser is Chrome");
        } else {
            resp.getWriter().println("Your browser is not Chrome");
        }
    }
}
